const express = require("express")
const mongoose = require('mongoose')
const bodyParser = require('body-parser')
const passport = require('passport')
const app = express();
const users = require('./router/api/user')
const profile = require('./router/api/profile')
const order = require('./router/api/order')
const notice = require('./router/api/notice')
const admin = require('./router/api/admin')
const offline = require('./router/api/offline')
mongoose.connect('mongodb://localhost/health_server')
    .then(() => console.log('数据库连接成功'))
    .catch(err => console.log(err, '连接失败'))
app.use(bodyParser.urlencoded({ extended: false }))
app.use(bodyParser.json())
app.use(passport.initialize())
require('./config/passportbulid')(passport)
app.use("/api/users", users)
app.use('/api/profile',profile)
app.use('/api/order',order)
app.use('/api/notice',notice)
app.use('/api/admin',admin)
app.use('/api/offline',offline)
const port = process.env.PORT || 5000;
app.listen(port, () => {
    console.log(`服务器已启动 ${port}`)
})